/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package casino;

/**
 * Abstract class used as the superclass for all of the states in the 1-3-2-6 betting system.
 * 
 * @author  amaghfur
 * @since   1.0
 */
public abstract class Player1326State {
    
    /** the player in this state */
    protected Player1326 player;
    /** the bet multiplier used to determine the bet amount */
    protected Rational betMultiplier;
    /** the key for the state transitioned into after winning */
    protected String nextState;
    
    /**
     * Constructor for this abstract state.
     * 
     * @param playerInState player to be put in this state
     */
    public Player1326State(Player1326 playerInState) {
        player = playerInState;
    }
    
    /**
     * Constructs a new bet from the player's preferred outcome. Each subclass
     * has a different multiplier used when creating this bet.
     * 
     * @return 
     */
    public Bet currentBet() {
        return new Bet(betMultiplier.times(player.baseBet), player.outcome);
    }
    
    /**
     * Constructs and returns the new Player1326State instance to be used when the bet was a winner.
     * 
     * @return  the new state
     */
    public Player1326State nextWon() {
        return Player1326StateFactory.getStateFactory(player).getState(nextState);
    }
    
    /**
     * Constructs the new Player1326State instance to be used when the bet was a loser. It will
     * always be Player1326NoWins.
     * 
     * @return  the new state 
     */
    public Player1326State nextLost() {    
        return Player1326StateFactory.getStateFactory(player).getState("Player1326NoWins");
    }
     
}
